package com.atguigu.tx.dao.impl;

import com.atguigu.tx.dao.api.StudentDao;
import jakarta.annotation.Resource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class StudentDaoImpl implements StudentDao {

    @Resource
    private JdbcTemplate jdbcTemplate;

    @Override
    public void updateStuName(String stuName01, String stuId01) {
        String sql = "update students set name=? where id=?";
        jdbcTemplate.update(sql, stuName01, stuId01);
    }

    @Override
    public void updateStuAge(String stuAge02, String stuId02) {
        String sql = "update stude2nts set age=? where id=?";
        jdbcTemplate.update(sql, stuAge02, stuId02);
    }

    @Override
    public String selectStuName(String stuId) {
        String sql = "select name from students where id=?";
        return jdbcTemplate.queryForObject(sql, String.class, stuId);
    }
}
